package com.shigu.account.action;

import com.shigu.PageResponse;
import com.shigu.TokenRequest;
import com.shigu.account.api.VipManagerService;
import com.shigu.account.bo.CurDutiesRequest;
import com.shigu.account.bo.MyInviteRequest;
import com.shigu.account.service.UserService;
import com.shigu.account.vo.AllDutyVo;
import com.shigu.account.vo.InviteInfoVo;
import com.shigu.account.vo.InviteNumVo;
import com.shigu.account.vo.MyInviteVo;
import com.shigu.appVersion.bo.VersionRequest;
import com.shigu.appVersion.service.VersionService;
import com.shigu.trade.vo.AppWxPayResponse;
import com.shigu.user.service.MallTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/*
 * create by  过儿  2019-06-10
 * 移动端的
 */
@RequestMapping("wapsjson")
@Controller
public class VipWapController {

    @Resource(name = "vipManagerServiceImpl")
    VipManagerService vipManagerService;

    @Autowired
    MallTokenService mallTokenService;
    @Autowired
    VersionService versionService;

    @Autowired
    UserService userService;

    @RequestMapping("wxPayVip")
    @ResponseBody
    public AppWxPayResponse wxPayVip(TokenRequest request) throws Exception {
        Long mallUserId = mallTokenService.selUserIdByToken(request.getToken());
        return vipManagerService.wxPayVip(mallUserId);
    }

    @RequestMapping("getAllDutiesInfo")
    @ResponseBody
    public PageResponse<AllDutyVo> getAllDutiesInfo(VersionRequest request){
        return vipManagerService.getAllDutiesInfo(versionService.versionUri(request.getVersion(),request.getOs()));
    }

    @RequestMapping("getCurDutiesInfo")
    @ResponseBody
    public InviteInfoVo getCurDutiesInfo(CurDutiesRequest request){
        Long mallUserId = mallTokenService.selUserIdByToken(request.getToken());
        return vipManagerService.vipInviteInfo(mallUserId,versionService.versionUri(request.getVersion(),request.getOs()));
    }

    @RequestMapping("getInviteUserInfo")
    @ResponseBody
    public PageResponse<MyInviteVo> selMyInvite(MyInviteRequest request){
        Long mallUserId = mallTokenService.selUserIdByToken(request.getToken());
        return userService.selMyInvite(request.getPage(),request.getSize(),mallUserId,request.getType());
    }

    @RequestMapping("getDiffInviteUserNum")
    @ResponseBody
    public InviteNumVo getDiffInviteUserNum(TokenRequest request){
        Long mallUserId = mallTokenService.selUserIdByToken(request.getToken());
        return userService.getDiffInviteUserNum(mallUserId);
    }
}
